package com.zjs.server.mongodb.contorller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class TestContorller {

    Integer count1 = 1;
    Integer count2 = 1;
    @GetMapping(value = "/test1")
    public String test1(){
        return "调用mongodb的test1方法 "+ count1++ +"次  "+new Date();
    }
    @GetMapping(value = "/test2/{name}")
    public String test2(@PathVariable(value = "name") String name){
        return "调用mongodb的test2方法 "+ count2++ +"次  "+new Date()+name;
    }

    @GetMapping(value = "/timeOut/{s}")
    public String timeOut(@PathVariable(value = "s") int s){
        try {
            Thread.sleep(s*1000);
            System.out.println("延迟"+s+" S "+new Date());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "主MongoDB  延迟"+s+" S "+new Date();
    }
}
